class Solution:
    def maxSlidingWindow(self, nums, k: int):
        result = []
        dic = []
        for i in range(len(nums)):
            if len(dic) == k:
                dic.remove(nums[i - k])
            j = 0
            while j < len(dic):
                if nums[i] <= dic[j]:
                    break
                j = j + 1
            dic.insert(j, nums[i])
            if len(dic) == k:
                result.append(dic[-1])
        return result


if __name__ == '__main__':
    so = Solution()
    nums = [1, 3, -1, -3, 5, 3, 6, 7]
    k = 3
    r = so.maxSlidingWindow(nums, k)
    print(r)
